class PortfolioController < ApplicationController
  include PortfolioHelper
  STOCKS = ['IBMW', 'MSFT', 'BEAS', 'SUNW']  

  def initialize
    $counter ||= 0
    $prices ||= {}
  end
     
  def index
  end

  def consumer
  end


  # produce stock price update, and send to MQ using STOMP
  def producer  
    @counter = $counter += 1
    @prices = $prices
    
    stock = STOCKS[(rand() * 4).to_i]    
    out = create_stock_text(stock)
    AjaxMessaging.send_data('STOCKS.' + stock.upcase, 'stocks', out)    
  end  
  
  private

end
